package com.ilop.sthome.ui.activity.login;

import android.os.Bundle;
import android.text.InputFilter;
import android.text.InputType;
import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;

import androidx.core.content.ContextCompat;

import com.alibaba.sdk.android.openaccount.ui.OpenAccountUIConfigs;
import com.alibaba.sdk.android.openaccount.ui.ui.ResetPasswordActivity;
import com.example.common.utils.SpUtil;
import com.ilop.sthome.common.CommonId;
import com.siterwell.familywellplus.R;

/**
 * @author skygge
 * @Date on 2019-09-25.
 * GitHub：javofxu@github.com
 * email：skygge@yeah.net
 * description：手机找回页面
 */
public class PhoneResetAliActivity extends ResetPasswordActivity {

    @Override
    protected String getLayoutName() {
        return "activity_phone_reset_ali";
    }

    @Override
    protected void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        OpenAccountUIConfigs.MobileResetPasswordLoginFlow.resetPasswordPasswordActivityClazz = ResetPasswordAliActivity.class;
        String phone = SpUtil.getString(this, CommonId.CHANGE_PASSWORD);
        if (!TextUtils.isEmpty(phone)){
            TextView title = findViewById(R.id.iv_reset_title);
            title.setText(getResources().getString(R.string.sys_update_pwd));
            this.mobileInputBox.getEditText().setText(phone);
            this.mobileInputBox.getEditText().setEnabled(false);
            this.mobileInputBox.getClearTextView().setVisibility(View.GONE);
        }
        this.mToolBar.setVisibility(View.GONE);
        this.smsCodeInputBox.getSend().setText(getResources().getString(R.string.phone_reset_page_code_button_text));
        this.smsCodeInputBox.getSend().setTextColor(ContextCompat.getColor(this, R.color.main_color));
        this.smsCodeInputBox.setSendText("get_code");
        this.smsCodeInputBox.getEditText().setFilters(new InputFilter[]{new InputFilter.LengthFilter(6)});
        this.smsCodeInputBox.getEditText().setInputType(InputType.TYPE_CLASS_NUMBER);
        this.mobileInputBox.getEditText().setFilters(new InputFilter[]{new InputFilter.LengthFilter(11)});
        this.mobileInputBox.setSupportForeignMobile(this,null,false);
        findViewById(R.id.iv_reset_back).setOnClickListener(view -> finish());
    }

}
